<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        function dateFormat(input,format){
            let day = input.getDate();
            let month = input.getMonth();
            let year = input.getFullYear();
            format = format.replace("yyyy",year)
            format = format.replace("MM",month)
            format = format.replace("dd",day)
            return format
        }



        dateFormat(new Date('2020-12-01'), 'yyyy/MM/dd') // 2020/12/01
        dateFormat(new Date('2020-04-01'), 'yyyy/MM/dd') // 2020/04/01
        dateFormat(new Date('2020-04-01'), 'yyyy年MM月dd日') // 2020年04月01日
    </script>
</body>

</html>